package io.renren.modules.evaluate.service.imp;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.modules.evaluate.dao.IndexSystemDao;
import io.renren.modules.evaluate.entity.IndexSystemEntity;
import io.renren.modules.evaluate.entity.IndexSystemMidEntity;
import io.renren.modules.evaluate.service.IndexSystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IndexSystemServiceImp extends ServiceImpl<IndexSystemDao,IndexSystemEntity> implements IndexSystemService{


    @Autowired
    IndexSystemDao indexSystemDao;

    /**
     * 根据用户id得到所有指标体系名称
     * */

    public List<IndexSystemEntity> findAllByUserId(Long userid){
        return indexSystemDao.findAll(userid);
    }

    /**
     * 新增指标体系
     * */

    public int insertIndexSystem(IndexSystemEntity ise){return indexSystemDao.insertIndexSystem(ise);}

    /**
     * 新增指标体系中间表
     * **/
    public int insertIndexSystemMid(IndexSystemMidEntity isme){return indexSystemDao.insertIndexSystemMid(isme);}

    @Override
    public IndexSystemEntity getById(Integer id){
        return baseMapper.getById(id);
    }

    @Override
    public List<IndexSystemMidEntity> getIdxSysMidById(Integer id) {
        return baseMapper.getIdxSysMidById(id);
    }
/*-------------------------------------------------------------------------------------------------------*/
    /**
     * 删除原有指标体系
     * */
    public int delIndexSystemByName(String name){return indexSystemDao.delIndexSystemByName(name);}

    public int delIndexSystemMidById(Integer id){return indexSystemDao.delIndexSystemMidById(id);}

    public IndexSystemEntity selByName(String name){return indexSystemDao.selByName(name);}
/*------------------------------------------------------------------------------------------------------*/

    /**
     * 逻辑上删除指标体系
     */
    @Override
    public Integer deleteByIdxSysId(Integer id) {
        return baseMapper.deleteByIdxSysId(id);
    }

}
